export const isMobile = (s) => {
	return /^(0|86|17951)?(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/.test(s)
}
export const isTelephone = (s) => {
	return /^1[0-9]{10}$/.test(s)
}
export const isEmail = (s) => {
	return /\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/.test(s);
}
export const formatBytes = (bytes, decimals = 2) => {
	if (bytes === 0) return '0 B'; //Bytes
	const k = 1024;
	const dm = decimals < 0 ? 0 : decimals;
	const sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
	const i = Math.floor(Math.log(bytes) / Math.log(k));
	return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
}
export const getCookie = (name) => {
	let reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
	let arr = document.cookie.match(reg)
	if (arr) {
		return unescape(arr[2]);
	} else {
		return '';
	}
}